import { useEffect } from 'react'
import axios from 'axios'
import { useTranslation } from 'react-i18next';
import { Button, Select } from 'antd';

function Index() {
  const { t, i18n } = useTranslation()
  const lang=localStorage.getItem('lang')||i18n.language||'zh'

    useEffect(()=>{
        axios.get('/api/article/list')
    },[])

    const yy=(value:string)=>{
        i18n.changeLanguage(value)
        localStorage.setItem('lang',value)
    }

  return (
    <div>
        <Select
              defaultValue={lang}
              style={{ width: 120 }}
              onChange={yy}
              options={[
                { value: 'en', label: 'English' },
                { value: 'zh', label: '中文' }
              ]}
            />
      <div className='bg-amber-300 w-[200px] h-[200px] text-sky-500'>
        data
      </div>
      <div>
        {t('Welcome to React')}
      </div>
    </div>
  )
}

export default Index
